<?php
use app\cls\tom\Response;
use app\cls\tom\SysResource;
use app\model\Topic;
require_once dirname(__DIR__)."/login_filter.php";
$uuid=$Auth['uuid'];
$video_uuid=$_REQUEST['video_uuid'];
if(empty($video_uuid)){
    Response::output(-1,"参数错误");
}
//实例化数据库
$db = SysResource::getDB(false);
$Topic = new Topic($db);
//根据话题id，查询话题分类
$video_detail=$Topic->one_love($video_uuid);


//再去根据用户自己的ID去查询用户点赞和关注了哪些视频

//$uuid=2;
//查询已点赞视频
$zan=$Topic->zan($uuid);
//查询已关注视频
$guanzu=$Topic->guanzu($uuid);
$zans=[];
$guanzus=[];
if(!empty($video_detail)){
    foreach($zan as $k=>$v){
        $zans[]=$v['video_uuid'];
    }
    foreach($guanzu as $kk=>$vv){
        $guanzus[]=$vv['video_uuid'];
    }

    if(in_array($video_detail['video_uuid'],$zans)){
        $video_detail['is_zan']=2;
    }else{
        $video_detail['is_zan']=1;
    }
    if(in_array($video_detail['uuid'],$guanzus)){
        $video_detail['is_follow']=2;
    }else{
        $video_detail['is_follow']=1;
    }
    if($video_detail['uuid']==$uuid){
        $video_detail['is_follow']=3;
    }

}
Response::output(0,"查询成功",$video_detail);
